package bufferedstream;

import java.io.*;
import java.util.*;

public class Test03 {
    public static void main(String[] args) throws IOException {
        //利用map里面的自动排序
        BufferedReader br = new BufferedReader(new FileReader("csb.txt"));
        String b;
        TreeMap<Integer,String> tm = new TreeMap<>();
        while ((b = br.readLine()) != null) {
            String[] split = b.split("\\.");
            tm.put(Integer.parseInt(split[0]),b);
        }
        br.close();
        BufferedWriter bw = new BufferedWriter(new FileWriter("result.txt"));
        Set<Map.Entry<Integer, String>> entries = tm.entrySet();
        for (Map.Entry<Integer, String> entry : entries) {
            String value = entry.getValue();
            bw.write(value);
            bw.newLine();
        }
        bw.close();
    }
}
